//4
//1 1 2 2

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let n;
let initArr = [];
rl.on("line", (line) => {
    if (n === undefined) {
        n = Number(line.trim())
    } else if (initArr.length === 0) {
        initArr = line.trim().split(/\s+/).map(Number)
        console.log(getResult(n, initArr))
        // clear
        n = undefined
        initArr.length = 0
    }

})

function getResult(n, initArr) {
    let sum = initArr.reduce((acc, num) => acc + num , 0)
    let v = sum/2
    if(!Number.isInteger(v)) {
        return -1
    }

    // 使用背包算法, 背包容量为sum/2, 装最少的物品
    let dp = new Array(n + 1).fill(0).map(_ => new Array(v + 1).fill(0))
    for (let i = 1; i <= v ; i++) {
        dp[0][i] = n
    }

    for (let i = 1; i <= n ; i++) {
        for (let j = 1; j <= v ; j++) {
            let weight = initArr[i - 1]
            if(weight <= j){
                // 能装下 当前石头
                dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - weight] + 1)
            } else {
                dp[i][j] = dp[i - 1][j]
            }
        }
    }

    if(dp[n][v] === n) {
        return -1
    } else {
        return dp[n][v]
    }
}